import web
import config
import hashlib

class login:
  def POST(self):
    try:
      i = web.input()
      m = hashlib.md5()
      m.update(i.username + i.password)
      psw = m.hexdigest()
      sql = "select * from members where username = '{0}' and password = '{1}'".format(i.username, psw)
      result = config.db.query(sql)
      if result.__len__() == 0:
        return 'username or password is incorect'
      return 'login successfully'
    except:
      return 'internal error!'